package org.opensource.home;

import org.opensource.home.service.CarService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@Controller
public class CarListController {

	@Autowired
	private CarService carService; //AutoWired replaces "CarService carService = new CarService()" and needs @Service in carService;
	
	@RequestMapping(value="/carList", method=RequestMethod.GET)
	public String handleRequest(Model model) {
		model.addAttribute("carList", carService.getCarList());
		return "carListView";
	}
}
